// pages/my/cash/recharge.js
const App = getApp()

Page({
  data: {

    cashTotal:0.00,

    show: !0,
    form: {
      name: '',
      is_def: !1,
    },
    //自动弹出键盘
    focus:true,

  },




  onLoad: function (options) {


    this.setData({
      cashTotal: options.cashTotal
    })


    this.WxValidate = App.WxValidate({
      money: {
        required: true,
        minlength: 1,
        maxlength: 10,
        number:true,
      },
    }, {
        money: {
          required: '请输入充值金额',
        },
      })

  },


  submitForm(e) {
    const params = e.detail.value

    console.log("--------params----------")
    console.log(params)
    console.log(params.money)
    console.log("--------params----------")

    if (!this.WxValidate.checkForm(e)) {
      const error = this.WxValidate.errorList[0]
      App.WxService.showModal({
        title: '友情提示',
        content: `${error.msg}`,
        showCancel: !1,
      })
      return false
      
    } else if (params.money <= 0) {
      App.WxService.showModal({
        title: '友情提示',
        content: `请输入正确金额`,
        showCancel: !1,
      })
      return false
    } else if (params.money > 1000) {
      App.WxService.showModal({
        title: '友情提示',
        content: `最大充值限额为1000元`,
        showCancel: !1,
      })
      return false
    }


    // App.HttpService.postAddress(params)
    /**
    this.address.saveAsync(params)
      .then(res => {
        const data = res.data
        console.log(data)
        if (data.meta.code == 0) {
          this.showToast(data.meta.message)
        }
      })
     */

    //console.log(e)
    App.WxService.navigateTo('/pages/my/cash/affirmRecharge?money=' + params.money)

  },



  showToast(message) {
    App.WxService.showToast({
      title: message,
      icon: 'success',
      duration: 1500,
    })
      .then(() => App.WxService.navigateBack())
  },



})